/**
 * 
 */
package com.demo2do.boyle.common.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.demo2do.boyle.common.entity.geo.Geo;
import com.demo2do.boyle.common.entity.geo.Level;
import com.demo2do.core.persistence.GenericDaoSupport;

/**
 * @author downpour
 *
 */
@Repository("geoDaoSupport")
public class GeoDaoSupport {
	
	@Autowired
	private GenericDaoSupport genericDaoSupport;
	
	/**
	 * List Active Geo by level
	 * 
	 * @param level
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Geo> listGeo(Level level) {
		return genericDaoSupport.searchForCacheableList("FROM Geo geo WHERE geo.disabled = false AND geo.active = true AND geo.level = :level", "level", level);
	}
	
	/**
	 * List Enabled Geo by level
	 * @param level
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Geo> liseEnabledGeo(Level level) {
		return genericDaoSupport.searchForCacheableList("FROM Geo geo WHERE geo.disabled = false AND geo.level = :level", "level", level);
	}
	
	/**
	 * List Geo by active flag
	 * 
	 * @param active
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Geo> listGeo(boolean active) {
		
		return genericDaoSupport.searchForCacheableList("FROM Geo geo WHERE geo.disabled = false AND geo.active = :active", "active", active);
	}
	
}
